#pragma once

#include "molecular_atom.h"
#include "models/atom_interface/ai_window_info_fetcher.h"

class WindowInfoFetcher :
    public M::Atom
{
public:
    WindowInfoFetcher();
    virtual ~WindowInfoFetcher();

    virtual M::String name() const { return PAN_WINDOW_INFO_FETCHER; }
    virtual bool OnEvent(const M::AtomEndPoint &oSrcAtom, int nEventId, void *pParams);
    virtual bool OnExecute(const M::AtomEndPoint &oSrcAtom, int nFuncId, void *pParams, void *pIOParams);

protected:
    bool RetrieveInfo();
    void ResetInfo();

    bool OnGetWindowProcInfo(WindowProcInfo *pParams);
    bool OnGetWindowThreadInfo(WindowThreadInfo *pParams);
    bool OnGetWindowInfo(WindowInfo *pParams);
    bool OnGetWindowProps(WindowProps *pParams);
    bool OnGetWindowProp(WindowPropKey *pKey, HANDLE *pValue);
    bool OnSetWindowProp(WindowPropKey *pKey, HANDLE hValue);
    bool OnRemoveWindowProp(WindowPropKey *pKey);

    static BOOL CALLBACK PropEnumProcEx(HWND hwnd, LPCTSTR lpszString, HANDLE hData, ULONG_PTR dwData);

private:
    WindowProcInfo m_oProcInfo;
    WindowThreadInfo m_oThreadInfo;
    WindowInfo m_oWindowInfo;
    WindowProps m_oProps;
};